package com.ap.core.domain;

import javax.persistence.Embeddable;
import java.io.Serializable;


/**
 * Specific type representing an account number.
 */
@Embeddable
public final class RollNumber implements Serializable{

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/** String value of the roll number *. */
    private String rollNumber;

    /**
     * private constructor which creates a <code>RollNumber</code> using a supplied string representation of an roll number.
     * 
     * @param rollNumber the roll number
     */
    private RollNumber(String rollNumber) {

        this.rollNumber = rollNumber;
    }

    /**
     * Protected no arg for JPA.
     */
    protected RollNumber() {
    }

    /**
     * Method to return an roll number.
     * 
     * @param rollNumber the roll number
     * 
     * @return RollNumber
     */
    public static RollNumber valueOf(String rollNumber) {

        return new RollNumber(rollNumber);
    }

    

    @Override
    public int hashCode() {
        return rollNumber.hashCode();
    }

    /**
     * 
     * {@inheritDoc}
     * 
     */
    @Override
    public boolean equals(Object o) {
        if (this == o){
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }    
        RollNumber comparison = (RollNumber) o;
        return rollNumber.equals(comparison.rollNumber);
    }


    @Override
    public String toString() {
        return rollNumber;
    }

}
